package com.atguigu.oss.controller;

import com.atguigu.commonutils.R;
import com.atguigu.oss.service.OssService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @Author: shaki
 * @Date: 2021/5/30 10:06
 */
@RestController
@RequestMapping("/eduoss/fileoss")
public class OssController {
    @Resource
    private OssService ossService;

    // 上传头像
    @PostMapping("upload")
    public R uploadOssFile(MultipartFile file) {
        //返回上传的路径
        String path = ossService.uploadFileAvatar(file);
        return R.ok().data("path",path);
    }
}
